Learn R Programming

daltoolbox (version 1.1.727)

[.ts_data: Subset Extraction for Time Series Data

Description

Extracts a subset of a time series object based on specified rows and columns. The function allows for flexible indexing and subsetting of time series data.

Usage

# S3 method for ts_data
[(x, i, j, ...)

Value

returns a new ts_data object

Arguments

x

ts_data object

i

row i

j

column j

...

optional arguments

Examples

Run this code
data(sin_data)
data10 <- ts_data(sin_data$y, 10)
ts_head(data10)
#single line
data10[12,]

#range of lines
data10[12:13,]

#single column
data10[,1]

#range of columns
data10[,1:2]

#range of rows and columns
data10[12:13,1:2]

#single line and a range of columns
#'data10[12,1:2]

#range of lines and a single column
data10[12:13,1]

#single observation
data10[12,1]

Run the code above in your browser using DataLab